package cn.yusei.teamTribe.dao.user;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import cn.yusei.teamTribe.dao.user.po.UserAuthPO;

@Component
public interface UserAuthDAO {

	final String USER_AUTH_TABLE = "e_user_auth";
	final String SELECT_FIELD = "id, email, phone";
	
	@Select({"select ", SELECT_FIELD, " from ", USER_AUTH_TABLE, " where id = #{id}"})
	UserAuthPO selectById(@Param("id") int id);
	
	@Select({"select email from ", USER_AUTH_TABLE, " where email = #{email} limit 1"})
	String selectEmail(@Param("email") String email);
	
	@Update({"update ", USER_AUTH_TABLE, " set email = #{email}, phone = #{phone} where id = #{id}"})
	void update(UserAuthPO user);
	
	@Select({"select phone from ", USER_AUTH_TABLE, " where phone = #{phone} limit 1"})
	String selectPhone(@Param("phone") String phone);

}
